package com.itany.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(urlPatterns = "/live",loadOnStartup = 1,initParams = {
        @WebInitParam(name = "username",value = "tom"),
        @WebInitParam(name = "password",value = "123")
})
public class LiveServlet extends HttpServlet {

    public LiveServlet(){
        System.out.println("LiveServlet被实例化。。。。。。。。");
    }

    @Override
    public void init() throws ServletException {
        System.out.println("LiveServlet正在初始化。。。。。。。");
        String username = getInitParameter("username");
        String password = getInitParameter("password");
        System.out.println(username+"-----------------"+password);

        String sex = getServletContext().getInitParameter("sex");
        System.out.println(sex);
    }

    // @Override
    // protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    //     System.out.println("LiveServlet正在提供服务。。。。。。");
    // }


    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("LiveServlet正在处理GET请求。。。。。");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("LiveServlet正在处理POST请求。。。。。");
    }

    @Override
    public void destroy() {
        System.out.println("LiveServlet将被销毁。。。。。。。。");
    }
}
